/*
**  Android Remote for Tux (AndroTux) 
**  Copyright (C) 2014 Itay Rom <1t4yr0m@gmail.com> Tal Sabo <tal.sabo@gmail.com> 
**
**  This program is free software: you can redistribute it and/or modify
**  it under the terms of the GNU General Public License as published by
**  the Free Software Foundation, either version 3 of the License, or
**  (at your option) any later version.
**
**  This program is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.androtux;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class GamepadFragment extends Fragment {
	/**
	 * A placeholder fragment containing a simple view.
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	        Bundle savedInstanceState) {
	    View rootView = inflater.inflate(R.layout.fragment_gamepad, container, false);

	    ToggleButton tbWheel = (ToggleButton)rootView.findViewById(R.id.gp_tbWheel);
	    tbWheel.setImage(R.drawable.wheel);
	    
	    tbWheel.addOnOps(new Runnable() {
			@Override
			public void run() {
				MainActivity.setAxis(true);
			}
		});
	    
	    tbWheel.addOffOps(new Runnable() {
			@Override
			public void run() {
				MainActivity.setAxis(false);
				CommunicationHandler.getInstance().sendData("a0,0");
			}
		});
	    
	    return rootView;
	}
}
